package sword2offer;

import java.util.ArrayList;
import java.util.List;

public class Offer006 {
    public int[] reversePrint(ListNode head) {
        if (head==null)return new int[0];
        int size=1;
        ListNode pre=null;
        while (head.next!=null) {
            ListNode next=head.next;
            head.next=pre;
            pre=head;
            head=next;
            size++;
        }
        head.next=pre;
        int []arr=new int[size];
        ListNode temp=head;
        for (int i = 0; i < size; i++) {
            arr[i]=temp.val;
            temp=temp.next;
        }
        return arr;
    }
}
